﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using Maticsoft.DBUtility;//Please add references
namespace ORSIMS.DAL
{
	/// <summary>
	/// 数据访问类:VECTOR_OTHER_METEDATA
	/// </summary>
	public partial class VECTOR_OTHER_METEDATA
	{
		public VECTOR_OTHER_METEDATA()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ORSIMS.Model.VECTOR_OTHER_METEDATA model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into VECTOR_OTHER_METEDATA(");
			strSql.Append("ID,TYPEID,TASKID,PRDUNIT,INCOMINGDATE,SCALE,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,UPPERRIGHTLONG,UPPERRIGHTLAT,LOWERLEFTLONG,OWERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,DATARESOURCE,DATAFILENAME,DATAFILEFMT,DATAFILEPATH,DATADISKINDEX,USERID,MATADATADATE,PRIVLEVEL,REMARK)");
			strSql.Append(" values (");
			strSql.Append(":ID,:TYPEID,:TASKID,:PRDUNIT,:INCOMINGDATE,:SCALE,:COORDINATESYSTEM,:UPPERLEFTLONG,:UPPERLEFTLAT,:UPPERRIGHTLONG,:UPPERRIGHTLAT,:LOWERLEFTLONG,:OWERLEFTLAT,:LOWERRIGHTLONG,:LOWERRIGHTLAT,:CENTERLONG,:CENTERLAT,:DATARESOURCE,:DATAFILENAME,:DATAFILEFMT,:DATAFILEPATH,:DATADISKINDEX,:USERID,:MATADATADATE,:PRIVLEVEL,:REMARK)");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10),
					new OracleParameter(":TYPEID", OracleType.VarChar,3),
					new OracleParameter(":TASKID", OracleType.VarChar,5),
					new OracleParameter(":PRDUNIT", OracleType.VarChar,90),
					new OracleParameter(":INCOMINGDATE", OracleType.DateTime),
					new OracleParameter(":SCALE", OracleType.Number,10),
					new OracleParameter(":COORDINATESYSTEM", OracleType.VarChar,20),
					new OracleParameter(":UPPERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":UPPERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":OWERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":CENTERLONG", OracleType.Number,10),
					new OracleParameter(":CENTERLAT", OracleType.Number,10),
					new OracleParameter(":DATARESOURCE", OracleType.VarChar,10),
					new OracleParameter(":DATAFILENAME", OracleType.VarChar,99),
					new OracleParameter(":DATAFILEFMT", OracleType.VarChar,30),
					new OracleParameter(":DATAFILEPATH", OracleType.VarChar,255),
					new OracleParameter(":DATADISKINDEX", OracleType.VarChar,90),
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":MATADATADATE", OracleType.DateTime),
					new OracleParameter(":PRIVLEVEL", OracleType.Number,1),
					new OracleParameter(":REMARK", OracleType.VarChar,20)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.TYPEID;
			parameters[2].Value = model.TASKID;
			parameters[3].Value = model.PRDUNIT;
			parameters[4].Value = model.INCOMINGDATE;
			parameters[5].Value = model.SCALE;
			parameters[6].Value = model.COORDINATESYSTEM;
			parameters[7].Value = model.UPPERLEFTLONG;
			parameters[8].Value = model.UPPERLEFTLAT;
			parameters[9].Value = model.UPPERRIGHTLONG;
			parameters[10].Value = model.UPPERRIGHTLAT;
			parameters[11].Value = model.LOWERLEFTLONG;
			parameters[12].Value = model.OWERLEFTLAT;
			parameters[13].Value = model.LOWERRIGHTLONG;
			parameters[14].Value = model.LOWERRIGHTLAT;
			parameters[15].Value = model.CENTERLONG;
			parameters[16].Value = model.CENTERLAT;
			parameters[17].Value = model.DATARESOURCE;
			parameters[18].Value = model.DATAFILENAME;
			parameters[19].Value = model.DATAFILEFMT;
			parameters[20].Value = model.DATAFILEPATH;
			parameters[21].Value = model.DATADISKINDEX;
			parameters[22].Value = model.USERID;
			parameters[23].Value = model.MATADATADATE;
			parameters[24].Value = model.PRIVLEVEL;
			parameters[25].Value = model.REMARK;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ORSIMS.Model.VECTOR_OTHER_METEDATA model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update VECTOR_OTHER_METEDATA set ");
			strSql.Append("ID=:ID,");
			strSql.Append("TYPEID=:TYPEID,");
			strSql.Append("TASKID=:TASKID,");
			strSql.Append("PRDUNIT=:PRDUNIT,");
			strSql.Append("INCOMINGDATE=:INCOMINGDATE,");
			strSql.Append("SCALE=:SCALE,");
			strSql.Append("COORDINATESYSTEM=:COORDINATESYSTEM,");
			strSql.Append("UPPERLEFTLONG=:UPPERLEFTLONG,");
			strSql.Append("UPPERLEFTLAT=:UPPERLEFTLAT,");
			strSql.Append("UPPERRIGHTLONG=:UPPERRIGHTLONG,");
			strSql.Append("UPPERRIGHTLAT=:UPPERRIGHTLAT,");
			strSql.Append("LOWERLEFTLONG=:LOWERLEFTLONG,");
			strSql.Append("OWERLEFTLAT=:OWERLEFTLAT,");
			strSql.Append("LOWERRIGHTLONG=:LOWERRIGHTLONG,");
			strSql.Append("LOWERRIGHTLAT=:LOWERRIGHTLAT,");
			strSql.Append("CENTERLONG=:CENTERLONG,");
			strSql.Append("CENTERLAT=:CENTERLAT,");
			strSql.Append("DATARESOURCE=:DATARESOURCE,");
			strSql.Append("DATAFILENAME=:DATAFILENAME,");
			strSql.Append("DATAFILEFMT=:DATAFILEFMT,");
			strSql.Append("DATAFILEPATH=:DATAFILEPATH,");
			strSql.Append("DATADISKINDEX=:DATADISKINDEX,");
			strSql.Append("USERID=:USERID,");
			strSql.Append("MATADATADATE=:MATADATADATE,");
			strSql.Append("PRIVLEVEL=:PRIVLEVEL,");
			strSql.Append("REMARK=:REMARK");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10),
					new OracleParameter(":TYPEID", OracleType.VarChar,3),
					new OracleParameter(":TASKID", OracleType.VarChar,5),
					new OracleParameter(":PRDUNIT", OracleType.VarChar,90),
					new OracleParameter(":INCOMINGDATE", OracleType.DateTime),
					new OracleParameter(":SCALE", OracleType.Number,10),
					new OracleParameter(":COORDINATESYSTEM", OracleType.VarChar,20),
					new OracleParameter(":UPPERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":UPPERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":OWERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":CENTERLONG", OracleType.Number,10),
					new OracleParameter(":CENTERLAT", OracleType.Number,10),
					new OracleParameter(":DATARESOURCE", OracleType.VarChar,10),
					new OracleParameter(":DATAFILENAME", OracleType.VarChar,99),
					new OracleParameter(":DATAFILEFMT", OracleType.VarChar,30),
					new OracleParameter(":DATAFILEPATH", OracleType.VarChar,255),
					new OracleParameter(":DATADISKINDEX", OracleType.VarChar,90),
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":MATADATADATE", OracleType.DateTime),
					new OracleParameter(":PRIVLEVEL", OracleType.Number,1),
					new OracleParameter(":REMARK", OracleType.VarChar,20)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.TYPEID;
			parameters[2].Value = model.TASKID;
			parameters[3].Value = model.PRDUNIT;
			parameters[4].Value = model.INCOMINGDATE;
			parameters[5].Value = model.SCALE;
			parameters[6].Value = model.COORDINATESYSTEM;
			parameters[7].Value = model.UPPERLEFTLONG;
			parameters[8].Value = model.UPPERLEFTLAT;
			parameters[9].Value = model.UPPERRIGHTLONG;
			parameters[10].Value = model.UPPERRIGHTLAT;
			parameters[11].Value = model.LOWERLEFTLONG;
			parameters[12].Value = model.OWERLEFTLAT;
			parameters[13].Value = model.LOWERRIGHTLONG;
			parameters[14].Value = model.LOWERRIGHTLAT;
			parameters[15].Value = model.CENTERLONG;
			parameters[16].Value = model.CENTERLAT;
			parameters[17].Value = model.DATARESOURCE;
			parameters[18].Value = model.DATAFILENAME;
			parameters[19].Value = model.DATAFILEFMT;
			parameters[20].Value = model.DATAFILEPATH;
			parameters[21].Value = model.DATADISKINDEX;
			parameters[22].Value = model.USERID;
			parameters[23].Value = model.MATADATADATE;
			parameters[24].Value = model.PRIVLEVEL;
			parameters[25].Value = model.REMARK;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from VECTOR_OTHER_METEDATA ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.VECTOR_OTHER_METEDATA GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,TYPEID,TASKID,PRDUNIT,INCOMINGDATE,SCALE,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,UPPERRIGHTLONG,UPPERRIGHTLAT,LOWERLEFTLONG,OWERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,DATARESOURCE,DATAFILENAME,DATAFILEFMT,DATAFILEPATH,DATADISKINDEX,USERID,MATADATADATE,PRIVLEVEL,REMARK from VECTOR_OTHER_METEDATA ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			ORSIMS.Model.VECTOR_OTHER_METEDATA model=new ORSIMS.Model.VECTOR_OTHER_METEDATA();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.VECTOR_OTHER_METEDATA DataRowToModel(DataRow row)
		{
			ORSIMS.Model.VECTOR_OTHER_METEDATA model=new ORSIMS.Model.VECTOR_OTHER_METEDATA();
			if (row != null)
			{
				if(row["ID"]!=null && row["ID"].ToString()!="")
				{
					model.ID=decimal.Parse(row["ID"].ToString());
				}
				if(row["TYPEID"]!=null)
				{
					model.TYPEID=row["TYPEID"].ToString();
				}
				if(row["TASKID"]!=null)
				{
					model.TASKID=row["TASKID"].ToString();
				}
				if(row["PRDUNIT"]!=null)
				{
					model.PRDUNIT=row["PRDUNIT"].ToString();
				}
				if(row["INCOMINGDATE"]!=null && row["INCOMINGDATE"].ToString()!="")
				{
					model.INCOMINGDATE=DateTime.Parse(row["INCOMINGDATE"].ToString());
				}
				if(row["SCALE"]!=null && row["SCALE"].ToString()!="")
				{
					model.SCALE=decimal.Parse(row["SCALE"].ToString());
				}
				if(row["COORDINATESYSTEM"]!=null)
				{
					model.COORDINATESYSTEM=row["COORDINATESYSTEM"].ToString();
				}
				if(row["UPPERLEFTLONG"]!=null && row["UPPERLEFTLONG"].ToString()!="")
				{
					model.UPPERLEFTLONG=decimal.Parse(row["UPPERLEFTLONG"].ToString());
				}
				if(row["UPPERLEFTLAT"]!=null && row["UPPERLEFTLAT"].ToString()!="")
				{
					model.UPPERLEFTLAT=decimal.Parse(row["UPPERLEFTLAT"].ToString());
				}
				if(row["UPPERRIGHTLONG"]!=null && row["UPPERRIGHTLONG"].ToString()!="")
				{
					model.UPPERRIGHTLONG=decimal.Parse(row["UPPERRIGHTLONG"].ToString());
				}
				if(row["UPPERRIGHTLAT"]!=null && row["UPPERRIGHTLAT"].ToString()!="")
				{
					model.UPPERRIGHTLAT=decimal.Parse(row["UPPERRIGHTLAT"].ToString());
				}
				if(row["LOWERLEFTLONG"]!=null && row["LOWERLEFTLONG"].ToString()!="")
				{
					model.LOWERLEFTLONG=decimal.Parse(row["LOWERLEFTLONG"].ToString());
				}
				if(row["OWERLEFTLAT"]!=null && row["OWERLEFTLAT"].ToString()!="")
				{
					model.OWERLEFTLAT=decimal.Parse(row["OWERLEFTLAT"].ToString());
				}
				if(row["LOWERRIGHTLONG"]!=null && row["LOWERRIGHTLONG"].ToString()!="")
				{
					model.LOWERRIGHTLONG=decimal.Parse(row["LOWERRIGHTLONG"].ToString());
				}
				if(row["LOWERRIGHTLAT"]!=null && row["LOWERRIGHTLAT"].ToString()!="")
				{
					model.LOWERRIGHTLAT=decimal.Parse(row["LOWERRIGHTLAT"].ToString());
				}
				if(row["CENTERLONG"]!=null && row["CENTERLONG"].ToString()!="")
				{
					model.CENTERLONG=decimal.Parse(row["CENTERLONG"].ToString());
				}
				if(row["CENTERLAT"]!=null && row["CENTERLAT"].ToString()!="")
				{
					model.CENTERLAT=decimal.Parse(row["CENTERLAT"].ToString());
				}
				if(row["DATARESOURCE"]!=null)
				{
					model.DATARESOURCE=row["DATARESOURCE"].ToString();
				}
				if(row["DATAFILENAME"]!=null)
				{
					model.DATAFILENAME=row["DATAFILENAME"].ToString();
				}
				if(row["DATAFILEFMT"]!=null)
				{
					model.DATAFILEFMT=row["DATAFILEFMT"].ToString();
				}
				if(row["DATAFILEPATH"]!=null)
				{
					model.DATAFILEPATH=row["DATAFILEPATH"].ToString();
				}
				if(row["DATADISKINDEX"]!=null)
				{
					model.DATADISKINDEX=row["DATADISKINDEX"].ToString();
				}
				if(row["USERID"]!=null)
				{
					model.USERID=row["USERID"].ToString();
				}
				if(row["MATADATADATE"]!=null && row["MATADATADATE"].ToString()!="")
				{
					model.MATADATADATE=DateTime.Parse(row["MATADATADATE"].ToString());
				}
				if(row["PRIVLEVEL"]!=null && row["PRIVLEVEL"].ToString()!="")
				{
					model.PRIVLEVEL=decimal.Parse(row["PRIVLEVEL"].ToString());
				}
				if(row["REMARK"]!=null)
				{
					model.REMARK=row["REMARK"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,TYPEID,TASKID,PRDUNIT,INCOMINGDATE,SCALE,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,UPPERRIGHTLONG,UPPERRIGHTLAT,LOWERLEFTLONG,OWERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,DATARESOURCE,DATAFILENAME,DATAFILEFMT,DATAFILEPATH,DATADISKINDEX,USERID,MATADATADATE,PRIVLEVEL,REMARK ");
			strSql.Append(" FROM VECTOR_OTHER_METEDATA ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM VECTOR_OTHER_METEDATA ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T. desc");
			}
			strSql.Append(")AS Row, T.*  from VECTOR_OTHER_METEDATA T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "VECTOR_OTHER_METEDATA";
			parameters[1].Value = "";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

